﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="xEducationDetails.aspx.cs" Inherits="UIDocument.DocumentFile.Education.xEducationDetails" %>
<%@ Register src="../../UserControl/ucFileUpload.ascx" tagname="ucFileUpload" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../../JavaScript/validationForEducationPage.js" type="text/javascript"></script>
    <style type="text/css">
        #Select2
        {
            width: 127px;
        }
        #selectPassingYear
        {
            width: 125px;
        }
    .style4
    {
        width: 207px;
    }
    #txtCollegeName
    {
        width: 191px;
    }
    #txtCourseName
    {
        width: 194px;
    }
    #txtSemesterName
    {
        width: 192px;
    }
    #txtTotalSubject
    {
        width: 192px;
    }
    #txtGetMarks
    {
        width: 188px;
    }
    </style>
    <script type ="text/javascript">
    //rollnumber, CourseName, registerNumber, semesterName, universityName, totalSubject, totalMarks, getMarks, passingYear
        $(document).ready(function () {
            var passingOfYear = new Date();
            passingOfYear = passingOfYear.getFullYear() - 50;
            var pyear = new Date();
            pyear = pyear.getFullYear();
            var option = "<option value ='N/A'>Select Year </option>";
            for (; passingOfYear <= pyear; passingOfYear++) {
                option += "<option value ='" + passingOfYear + "'>" + passingOfYear + "</option>";
            }

            $("#selectPassingYear").empty().append(option);

            $("#btnSubmit").click(function () {
                educationValidation();
               
            });

        });

        function educationValidation() {
            var schoolName = $("#txtSchoolName").val().trim();
            var rollNumber = $("#txtRollNumber").val().trim();
            var className = $("#txtClassName").val().trim();
            var registrationNumber = $("#txtRegistrtionNumber").val().trim();
            var semesterName = $("#txtSemesterName").val().trim();
            var boardName = $("#txtBoardName").val().trim();
            var totalSubject = $("#txtTotalSubject").val().trim();
            var totalMark = $("#txtTotalMark").val().trim();
            var getMarks = $("#txtGetMarks").val();
            var passingOfYear = $("#selectPassingYear").val();
           // alert(passingOfYear);
            debugger;
            if (schoolName == "") {
                alert('please enter school name');
                return false;
            }
            if (rollNumber == "") {
                return false;
            }
            if (className == "") {
                return false;
            }
            if (registrationNumber == "") {
                return false;
            }
//            if (semesterName == "") {
//                return false;
//            }
            if (totalSubject == "") {
                return false;
            }
            if (totalMark == "") {
                return false;
            }
            if (getMarks == "") {
                return false;
            }
            if (passingOfYear == "N/A") {
                return false;
            }
          //  var educationDetail = '{"schoolName" : "' + schoolName + '" , "rollNumber" :"' + rollNumber + '" , "className" : "' + className + '" , "registrationNumber" :"' + registrationNumber + '" , "semesterName" : "' + semesterName + '" ,"boardName" : "' + boardName + '" ,"totalSubject" : "' + totalSubject + '" , "totalMark" : "' + totalMark + '" ,"getMarks" : "' + getMarks + '" , "passingOfYear" :"' + passingOfYear + '","fileName":"' + document.getElementById("hdUploadFileName").getAttribute("value") + '"}';

          //  alert('{"schoolName" : "' + schoolName + '" , "rollNumber" :"' + rollNumber + '" , "className" : "' + className + '" , "registrationNumber" :"' + registrationNumber + '" , "semesterName" : "' + semesterName + '" ,"boardName" : "' + boardName + '" ,"totalSubject" : "' + totalSubject + '" , "totalMark" : "' + totalMark + '" ,"getMarks" : "' + getMarks + '" , "passingOfYear" :"' + passingOfYear + '","fileName":"' + document.getElementById("hdUploadFileName").getAttribute("value") + '"}');
            $.ajax({

                url: "/UIDocument/WebForm3.aspx/EducationDetail",
                type: "POST",
               // data: '{"educationDetail" :"' + educationDetail + '"}',
                data: '{"schoolName" : "' + schoolName + '" , "rollNumber" :"' + rollNumber + '" , "className" : "' + className + '" , "registrationNumber" :"' + registrationNumber + '" , "semesterName" : "' + semesterName + '" ,"boardName" : "' + boardName + '" ,"totalSubject" : "' + totalSubject + '" , "totalMark" : "' + totalMark + '" ,"getMarks" : "' + getMarks + '" , "passingOfYear" :"' + passingOfYear + '","fileName":"'+document.getElementById("hdUploadFileName").getAttribute("value")+'"}',
                dataType: "json",
                contentType: "application/json",
                success: function (_data) {
                    debugger;
                    alert(_data.d.Data);
                    if (_data.d.Data == true) {
                        alert(_data.d.ErrorMessage);

                    }
                    else { alert(_data.d.ErrorMessage) }
                },
                error: function () { }
            });
           
        }

       

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <input id="hdUploadFileName" type="hidden" value ="" />
    <table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 442px">
        <tbody><tr>
            <td width="26">
            </td>
            <td>
                &nbsp;<span id="Span1" style="color: red; display: none;"></span>
                <div id="Div1" style=" display:none;"> </div>
                </td>
            <td width="26">
                &nbsp;</td>
        </tr>
        <tr>
            <td background="../../Quick%20Links/Portalimages/transBG_12.png" width="26">
                &nbsp;</td>
            <td background="../../Quick%20Links/Portalimages/transBG_22.png">
                <div id="Div2" style="z-index: 860;">
                    <table border="1" bordercolor="#cdcdcd" cellpadding="4" cellspacing="0" style="width: 714px; border-collapse: collapse">
                        <tbody><tr>
                            <td style="font-size: 22px;">
                                Online Documentation</td>
                        </tr>
                        <tr>
                            <td>
                                <fieldset>
                                    <legend style="font-family: Tahoma; font-size: 11pt"><strong style="color: #990000">EDUCATION DETAILS</strong></legend>
                                    <table border="1" bordercolor="#cdcdcd" cellpadding="4" cellspacing="0" style="width: 100%; border-collapse: collapse">
                                        <tbody><tr>
                                            <td class="style4">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                &nbsp;Enter College\School Name :</strong><span class="fieldreq" style="color: #cc0000"> *</span></span></span></span></td>
                                            <td style="width: 90px">
                                                <input id="txtSchoolName" name="txtSchoolName" tabindex="0" type="text"></td>
                                            <td class="style2">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                Enter Roll Number : </strong></span>  
                                                    <span style="color: #cc0000"><span style="color: #cc0000">*</span></span></span></span></td>
                                            <td style="width: 100px">
                                                <input id="txtRollNumber" name="txtRollNumber" tabindex="1" type="text"></td>
                                        </tr>
                                        <tr>
                                            <td class="style4">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                Enter Course\class Name : </strong><span *<="" span="" style="color: #cc0000">
                                                <span style="color: #cc0000">*</span></span></span></span></span></td>
                                            <td style="width: 90px">
                                                <input id="txtClassName" name="txtClassName" 
                                                    onclick="return txtCardNumber_onclick()" size="20" tabindex="2" type="text"></td>
                                            <td class="style2">
                                                <span style="font-size: 10pt"><strong><span style="font-family: Tahoma">Enter 
                                                Registration Number :</span> </strong><font size="1"><span class="fieldreq" style="color: #cc0000; font-family: Tahoma">*</span></font></span></td>
                                            <td style="width: 100px">
                                                <input id="txtRegistrtionNumber" name="txtRegistrtionNumber" tabindex="3" 
                                                    type="text"></td>
                                        </tr>
                                        <tr>
                                            <td class="style4">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                Enter Semester Name : </strong><span *<="" span="" style="color: #cc0000">
                                                <span style="color: #cc0000">*</span></span></span></span></span></td>
                                            <td style="width: 140px">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                <input id="txtSemesterName" name="txtSemesterName" size="20" type="text" 
                                                    tabindex="4"> </strong></span></span></span>
                                            </td>
                                            <td class="style2">
                                                <span style="font-size: 10pt"><strong><span style="font-family: Tahoma">
                                                University\Board Name :<span><span *<="" span="" style="color: #cc0000"><span style="color: #cc0000">*</span></span></span></span></strong></span></td>
                                            <td style="width: 100px">
                                                <input id="txtBoardName" name="txtBoardName" tabindex="5" type="text"></td>
                                        </tr>
                                            </tbody><caption>
                                                &nbsp;</caption>
                                            <tbody><tr>
                                            <td class="style4">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                Enter Total Subject :<span style="color: #cc0000">*</span></strong></span></span></span></td>
                                            <td style="width: 90px">
                                                <input id="txtTotalSubject" name="txtTotalSubject" tabindex="6" type="text"></td>
                                            <td class="style2">
                                                <span style="font-size: 10pt"><strong><span style="font-family: Tahoma">Total 
                                                Mark:<span><span *<="" span="" style="color: #cc0000"><span style="color: #cc0000">*</span></span></span></span></strong></span></td>
                                            <td style="width: 100px">
                                                <input id="txtTotalMark" name="txtTotalMark" tabindex="7" type="text"></td>
                                        </tr>
                                            </tbody>
                                            
                                            <tbody><tr>
                                            <td class="style4">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                &nbsp;Enter Get Marks :</strong><span class="fieldreq" style="color: #cc0000">*</span></span></span></span></td>
                                            <td style="width: 90px">
                                                <input id="txtGetMarks" name="txtGetMarks" tabindex="8" type="text"></td>
                                            <td class="style2">
                                                <span><span style="font-family: Tahoma"><span style="font-size: 10pt"><strong>
                                                Passing Of Year : </strong><span *<="" span="" style="color: #cc0000"><span style="color: #cc0000">*</span></span></span></span></span></td>
                                            <td style="width: 100px">
                                                <select id="selectPassingYear" name="D2" tabindex="9">
                                                    <option></option>
                                                </select></td>
                                        </tr>
                                           


                                              <tr>
                                            <td class="style3" colspan="4">
                                                
<style type="text/css">
    .style1
    {
        width: 392px;
    }
    .style2
    {
        width: 132px;
    }
    #Select1
    {
        width: 170px;
    }
    .style3
    {
        width: 289px;
    }
    #Submit1
    {
        width: 154px;
    }
    #File1
    {
        width: 291px;
    }
</style>
<script type="text/javascript">
    function fileUpload() {

        var _data = new FormData();
        _data.append("form", $('input[type=file]')[0].files[0]);
        alert('Ajax Call');
        $.ajax({
            url: "/UIDocument/HttpHandlerFile/FileUploder.ashx",
            data: _data,
            contentType: false,
            processData: false,
            type: "POST",
            success: function (sdata) { debugger; alert('File Upload Successfully ...' + sdata); document.getElementById("hdUploadFileName").setAttribute("value", sdata); alert(document.getElementById("hdUploadFileName").getAttribute("value")); alert($(sdata).toString().replace("FileName:", "").valueOf()); },
            error: function (a, b, c) { alert(b.innerText()); }
        });
    }

    function validation() {
        var sFileName = $("#uploadFile").val();
        if (sFileName.length > 0) {


            var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1];
            if (sFileExtension == "pdf" || sFileExtension == "doc" || sFileExtension == "docx" || sFileExtension == "jpg" || sFileExtension == "jpeg" || "xls") {
                fileUpload();
            }
            else {
                alert("Invalid File !!!!");
            }

        }
        else {
            alert("No File Choosen !!!!");
        }

    }
function btnFileUpload_onclick() {

}

</script>
<table class="style1">
    <tbody><tr>
        <td class="style2">
            <strong> Select File : </strong></td>
        <td class="style3">
            <input id="uploadFile" name="uploadFile" type="file" tabindex="10"></td>
    </tr>
    <tr>
        
        <td class="style3" colspan="2"><strong><div style="width: 378px; color:Red;">
            You can upload only (.txt ,jpeg,&nbsp; 
            .pdf, .doc )File</div></strong></td>
    </tr>
    <tr>
        <td class="style2">
            &nbsp;</td>
        <td class="style3"><strong>
            <input id="btnFileUpload" name="btnFileUpload" type="button" value="UPLOAD" 
                onclick=" return validation();" tabindex="11" onclick="return btnFileUpload_onclick()">
            </strong>
        </td>
    </tr>
</tbody></table>


                                                  </td>
                                        </tr>
                                            <tr>
                                            <td class="style4">
                                                &nbsp;</td>
                                            <td style="width: 90px">
                                                <span style="font-family: Tahoma"><strong>
                                                <input id="btnSubmit" name="btnSubmit" style=" font-weight:bold;" tabindex="12" 
                                                    type="button" value="Submit" onclick=" return Validation()" ;=""></strong></span></td>
                                            <td class="style2">
                                                <span style="font-family: Tahoma"><strong>
                                                <input id="Button4" name="" style=" font-weight:bold;" tabindex="13" 
                                                    type="button" value="Cancel"></strong> </span>
                                            </td>
                                            <td style="width: 100px">
                                                &nbsp;</td>
                                        </tr>
                                           
                                    </tbody></table>
                                </fieldset></td>
                        </tr>
                    </tbody></table>
                </div>
            </td>
        </tr>
    </tbody></table>
   <div id ="educationDetail">
   </div>
</asp:Content>
